*****Data Prep*****
import excel "C:\Users\ragusajm\Dropbox\rhetoric_repeals\analysis\complete_survey(3).xls", sheet("Sheet1") firstrow clear

set scheme plotplain

gen policy=1 if question=="reform"
replace policy=2 if question=="consumer"
replace policy=3 if question=="tax"
replace policy=4 if question=="agriculture"
label define policy 1 "Reform" 2 "Consumer" 3 "Taxes" 4 "Agriculture"
label value policy policy

replace outcome=(outcome*-1)
replace outcome=outcome+5
**Reverse coding the DV it so that higher values indicate greater support.
replace rep_treat=(rep_treat*-1)
replace rep_treat=rep_treat+1
**Reverse coding the treatements so that "1" is the repeal condition.

rename ideology self_ideology

drop if attn_check==0

alpha spending health jobs poor gov_purpose , gen(operational) i
corr pid self_ideology operational
**Creating the operational ideology measure.  

label variable self_ideology "Symbolic"
label variable operational "Operational"
label variable rep_treat "Repeal"


*****Primary Analysis******
ttest outcome, by(rep_treat)

reg outcome rep_treat i.policy, cluster(responseid)

reg outcome c.self_ideology##i.rep_treat i.policy, cluster(responseid)

margins, dydx(rep_treat) at(self_ideology=(1(1)7)) atmeans
marginsplot, ytitle("Repeal Treatment")  xtitle(" " "Symbolic Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Very" "Liberal" ""' 2 "Liberal" 3 `" "Somewhat" "Liberal" ""'4 "Moderate" 5 `" "Somewhat" "Conservative" ""' 6 "Conservative" 7 `" "Very" "Conservative" ""' , labsize(vsmall)) ylabel(-.3 -.2 -.1 0 .1 .2 .3 .4, labsize(vsmall)) xsize(19) ysize(15) graphregion(margin(0 10 0 0)) 

reg outcome c.operational##i.rep_treat i.policy, cluster(responseid)

margins, dydx(rep_treat) at(operational=(1(.3333)3)) atmeans
marginsplot, ytitle("Repeal Treatment") xtitle(" " "Operational Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Very" "Liberal" ""' 1.33 "Liberal" 1.66 `" "Somewhat" "Liberal" ""' 2 "Moderate" 2.33 `" "Somewhat" "Conservative" ""' 2.66 "Conservative" 3 `" "Very" "Conservative" ""' , labsize(vsmall)) ylabel(-.3 -.2 -.1 0 .1 .2 .3 .4, labsize(vsmall)) xsize(19) ysize(15) graphregion(margin(0 10 0 0))

mixed outcome c.self_ideology##i.rep_treat || policy: , vce(robust)

mixed outcome c.operational##i.rep_treat || policy: , vce(robust)


*****Policy Domain Variation*****
reg outcome i.policy##c.operational##i.rep_treat, cluster(responseid)

margins policy, dydx(rep_treat) at(operational=1) at(operational=3) atmeans
marginsplot, ytitle("Repeal Treatment", size(medsmall)) xtitle(" " "Policy Domain", size(medsmall))

margins policy, dydx(rep_treat) at(operational=1) at(operational=3) atmeans post
margins, coeflegend

test _b[1.rep_treat:1bn._at#1bn.policy] = _b[1.rep_treat:2._at#1bn.policy]
test _b[1.rep_treat:1bn._at#2.policy] = _b[1.rep_treat:2._at#2.policy]
test _b[1.rep_treat:1bn._at#3.policy] = _b[1.rep_treat:2._at#3.policy]
test _b[1.rep_treat:1bn._at#4.policy] = _b[1.rep_treat:2._at#4.policy]


*****Ideology Not Party*****
reg outcome c.operational##i.rep_treat c.pid##i.rep_treat i.policy, cluster(responseid)

margins, dydx(rep_treat) at(pid=(1(1)7)) atmeans
marginsplot, ytitle("Repeal Treatment") xtitle(" " "Partisanship", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Strong" "Democrat" ""' 2 "Democrat" 3 `" "Weak" "Democrat" ""' 4 "Independent" 5 `" "Weak" "Republican" ""' 6 "Republican" 7 `" "Strong" "Republican" ""' , labsize(vsmall)) ylabel(-.4 -.3 -.2 -.1 0 .1 .2 .3 .4 .5, labsize(vsmall)) xsize(19) ysize(15) graphregion(margin(0 10 0 0)) title(Party Interaction, size(medlarge)) 

margins, dydx(rep_treat) at(operational=(1(.3333)3)) atmeans
marginsplot, ytitle("Repeal Treatment") xtitle(" " "Operational Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Very" "Liberal" ""' 1.33 "Liberal" 1.66 `" "Somewhat" "Liberal" ""' 2 "Moderate" 2.33 `" "Somewhat" "Conservative" ""' 2.66 "Conservative" 3 `" "Very" "Conservative" ""' , labsize(vsmall)) ylabel(-.4 -.3 -.2 -.1 0 .1 .2 .3 .4 .5, labsize(vsmall)) xsize(19) ysize(15) graphregion(margin(0 10 0 0)) title(Ideology Interaction, size(medlarge))


*****Robustness Checks*****
ologit outcome c.operational##i.rep_treat i.policy, cluster(responseid)

margins, dydx(rep_treat) at(operational=(1(.3333)3)) atmeans predict(outcome(2)) predict(outcome(1))
marginsplot , ytitle("Repeal Treatment")  xtitle(" " "Symbolic Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Very" "Liberal" ""' 1.33 "Liberal" 1.66 `" "Somewhat" "Liberal" ""' 2 "Moderate" 2.33 `" "Somewhat" "Conservative" ""' 2.66 "Conservative" 3 `" "Very" "Conservative" ""' , labsize(vsmall)) ylabel(-.20 -.15 -.10 -.05 0 0.05 .10 .15, labsize(vsmall))  xsize(21) ysize(15) graphregion(margin(0 10 0 0)) legend(bmargin(zero)) legend (order(2 "Oppose" 1 "Strongly Oppose"))  title(Oppose Outcome, size(medlarge))

margins, dydx(rep_treat) at(operational=(1(.3333)3)) atmeans predict(outcome(3)) predict(outcome(4))
marginsplot , ytitle("Repeal Treatment")  xtitle(" " "Symbolic Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 `" "Very" "Liberal" ""' 1.33 "Liberal" 1.66 `" "Somewhat" "Liberal" ""' 2 "Moderate" 2.33 `" "Somewhat" "Conservative" ""' 2.66 "Conservative" 3 `" "Very" "Conservative" ""' , labsize(vsmall)) ylabel(-.20 -.15 -.10 -.05 0 0.05 .10 .15, labsize(vsmall)) xsize(21) ysize(15) graphregion(margin(0 10 0 0)) legend(bmargin(zero)) legend (order(1 "Support" 2 "Strongly Support")) title(Support Outcome, size(medlarge))

tab operational
gen Liberal=1 if operational<1.4
replace Liberal=0 if operational>=1.4 & operational!=.
gen Conservative=1 if operational>2.6
replace Conservative=0 if operational<=2.6 & operational!=.

reg outcome i.Conservative##i.rep_treat i.Liberal##i.rep_treat i.policy, cluster(responseid)

margins, dydx(rep_treat) at(Liberal=1 Conservative=0) at(Liberal=0 Conservative=0) at(Liberal=0 Conservative=1) atmeans
marginsplot , ytitle("Repeal Treatment")  xtitle(" " "Operational Ideology", size(medsmall)) title(" ") yline(0) xlabel(1 "Liberal" 2 "Moderate" 3 "Conservative" , labsize(vsmall)) ylabel(-.3 -.15 0 .15 .3 .45, labsize(vsmall)) xsize(21) ysize(15) graphregion(margin(0 10 0 0))  legend(bmargin(zero)) legend(order(off)) 




